<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- 用于指定双核浏览器默认以何种方式渲染页面 -->
    <meta name="renderer" content="webkit">
    <!-- 为移动设备添加 viewport；-->
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
    <!-- 删除苹果默认的工具栏和菜单栏 -->
    <meta name="apple-mobile-web-app-capable" content="yes"/>
    <!-- 设置苹果工具栏颜色 -->
    <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
    <!-- 针对手持设备优化，主要是针对一些老的不识别viewport的浏览器，比如黑莓 -->
    <meta name="HandheldFriendly" content="true">
    <!-- 微软的老式浏览器 -->
    <meta name="MobileOptimized" content="320">
    <!-- uc强制竖屏 -->
    <meta name="screen-orientation" content="portrait">
    <!-- QQ强制竖屏 -->
    <meta name="x5-orientation" content="portrait">
    <!-- UC强制全屏 -->
    <meta name="full-screen" content="yes">
    <!-- QQ强制全屏 -->
    <meta name="x5-fullscreen" content="true">
    <!-- UC应用模式 -->
    <meta name="browsermode" content="application">
    <!-- QQ应用模式 -->
    <meta name="x5-page-mode" content="app">
    <!-- windows phone 点击无高光 -->
    <meta name="msapplication-tap-highlight" content="no">
    <!-- 指定请求和响应遵循的缓存机制 -->
    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate"/>
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Expires" content="0" />
    <!-- 优先使用 IE 最新版本和 Chrome -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <title>AI大师写作 - 确认订单</title>
    <link rel="shortcut icon" href="../mobile/assets/icon.ico" type="image/vnd.microsoft.icon" />
    <link rel="stylesheet" href="../mobile/assets/css/bootstrap.min.css">
    <link rel="stylesheet" href="../mobile/assets/css/base.css">
    <link rel="stylesheet" href="../mobile/assets/css/common.css?v=16.5">
    <link rel="stylesheet" href="../mobile/assets/css/pay.css?v=17.1">
    <link rel="stylesheet" href="../mobile/assets/css/kefu.css?v=16.6">
    <script>
        var USER_TOKEN = 'RmlETkdPdjYzZmVjNTVhMDAyYzY='
        var JANE_NAME = 'dsxz'
    </script>
</head>
<body>
<div class="payApp">
    <div class="payAppBox">
        <div class="info">
            <h3>订单信息</h3>
            <div class="infoMain">
                <div class="infoLeft">标题</div>
                <div class="infoRight" id="title">正在获取</div>
                <div class="infoLeft">类型</div>
                <div class="infoRight" id="typeTag">正在获取</div>
                <div class="infoLeft NumberWordsBox">字数</div>
                <div class="infoRight NumberWordsBox" id="NumberWords">正在获取</div>
                <div class="infoLeft noPayWay Subject" style="display: none;">科目</div>
                <div class="infoRight noPayWay Subject" id="PaperTypeName" style="display: none;"></div>
                <div class="infoLeft">下单时间</div>
                <div class="infoRight" id="dateTime">正在获取</div>
                <div class="infoLeft">订单编号</div>
                <div class="infoRight" id="orderIdText">正在获取</div>
                <div class="infoLeft noPayWay">单价</div>
                <div class="infoRight noPayWay" id="priceTetx2"></div>
                <div class="infoLeft noPayWay">订单金额</div>
                <div class="infoRight noPayWay amountTextBox2">￥<span id="amountText2"></span></div>
            </div>
        </div>
        <div class="info appreciationInfo appreciation">
            <h3>增值服务</h3>
            <div class="appreciationUL">
                <div class="appreciationLI hasIntroduce" goodsid-key="" data-janename="zjcaigczz">
                    <div>
                        <div>
                            <i></i>
                        </div>
                        <div>
                            <span class="good_name"></span>
                            <img class="zjc-wh" src="../mobile/assets/img/wenhao-t.png" alt="">
                        </div>
                    </div>
                    <div class="priceBox">
                        <span class="price"></span>
                    </div>
                    <div class="introduce" style="width: 100%;">降低“AIGC检测系统”的AI疑似率</div>
                </div>
                <div class="appreciationLI hasIntroduce" goodsid-key="" data-janename="szsjzz" data-janename1="qkszsjzz">
                    <div>
                        <i></i>
                        <span class="good_name"></span>
                        <span class="szsj_notice">
                             <img src="../mobile/assets/img/wenhao.png" alt="">
                            购买须知
                        </span>
                    </div>
                    <div class="priceBox">
                        <span class="price"></span>
                    </div>
                    <div class="introduce szsj" style="width: 100%;">仅适用于文科专业，理工科慎选</div>
                </div>
                <div class="appreciationLI" goodsid-key="" data-janename="rws">
                    <div>
                        <i></i>
                        <span class="good_name"></span>
                    </div>
                    <div class="priceBox">
                        <span class="original-price"></span>
                        <span class="current-price"></span>
                    </div>
                </div>
                <div class="appreciationLI" goodsid-key="" data-janename="ktbg">
                    <div>
                        <i></i>
                        <span class="good_name"></span>
                    </div>
                    <div class="priceBox">
                        <span class="original-price"></span>
                        <span class="current-price"></span>
                    </div>
                </div>
                <div class="appreciationLI" goodsid-key="" data-janename="dbppt">
                    <div>
                        <i></i>
                        <span class="good_name"></span>
                    </div>
                    <div class="priceBox">
                        <span class="original-price"></span>
                        <span class="current-price"></span>
                    </div>
                </div>
            </div>
        </div>
        <div class="info couponBox">
            <input id="coupon" onKeyUp="value=value.replace(/[\W]/g,'')" type="text" placeholder="请输入优惠券码">
            <span class="use_now">兑  换</span>
        </div>
        <!-- 优惠券广告位-->
        <div class="claim-coupons">
            <img src="../mobile/assets/img/youhuiquan.png" alt="">
            领取优惠券
        </div>
        <div class="no_pay_text">该商家未开通扫码支付，此页面仅支持优惠券兑换</div>
        <div class="payType">
            <div class="payTypeBox" data-payType="alipayWap">
                <div class="tapTypeImg"><img src="../mobile/assets/img/zfb.png" alt=""> <span>支付宝支付</span> </div>
                <div class="isSelect isSelect1">
                    <img class="img" src="../mobile/assets/img/noselect.png" alt="">
                </div>
            </div>
            <div class="payTypeBox" id="wx-pay" data-payType="wxWap">
                <div class="tapTypeImg"><img src="../mobile/assets/img/wx.png" alt=""> <span>微信支付</span> </div>
                <div class="isSelect isSelect2">
                    <img class="img" src="../mobile/assets/img/noselect.png" alt="">
                </div>
            </div>
        </div>
        <div class="dsf-Pay taobao_pay" data-type="taobao" data-toggle="modal" data-target="#CustomModal">
            <div class="PayName">
                <img src="../mobile/assets/img/taobao.png" alt="">
                淘宝支付
            </div>
            <img class="noselectImg" src="../mobile/assets/img/noselect.png" alt="">
        </div>
        <div class="dsf-Pay redBook_pay" data-type="redBook" data-toggle="modal" data-target="#CustomModal">
            <div class="PayName">
                <img src="../mobile/assets/img/xhs.png" alt="">
                小红书支付
            </div>
            <img class="noselectImg" src="../mobile/assets/img/noselect.png" alt="">
        </div>
        <div class="case realTime">
            <img src="../mobile/assets/img/horn.png" alt="">
            <div class="t_news">
                <ul class="news_li">

                </ul>
                <ul class="swap"></ul>
            </div>
        </div>
    </div>

    <div class="bottomBox">
        <p>请在30分钟内完成支付，如未支付完成该订单将自动取消</p>
        <div class="payBox">
            <div class="amount">
                <div class="total">合计 <span>￥<span id="amountText"></span></span></div>
                <div>计费方式：<span id="priceTetx"></span></div>
            </div>
            <div class="payBotton">
                立即支付
            </div>
        </div>
    </div>
</div>
<div class="dashi_wx_box text_a_c">
    <div class="customerBox">
        <i class="close-wx"></i>
        <div class="head">
            <img src="../mobile/assets/img/kf.png" alt="">
            <span class="customer-title"></span>
        </div>
        <div class="customerCode">
            <img class="customer-qr" src="" alt="">
        </div>
        <div class="segmentation-line"></div>
        <div class="customerWay">
            <p class="wxText"><span class="s0">微信:</span> <span class="s1"></span></p>
            <p class="qqText"><span class="s0">Q Q:</span> <span class="s1"></span></p>
            <p class="telephone"><span class="s0">电话:</span> <span class="s1"></span></p>
            <p class="mailbox"><span class="s0">邮箱:</span> <span class="s1"></span></p>
        </div>
        <p class="noCustomer">商家未设置客服</p>
        <img class="customBg" src="../mobile/assets/img/bg1.png" alt="">
    </div>
</div>
<div class="mask"></div>
<div class="aigc-page">
    <img src="../mobile/assets/img/aigc-e.png" alt="">
    <img class="close-aigc" src="../mobile/assets/img/delete.png" alt="">
</div>
<div class="szsj-tips-block">
    <div class="head">
        <img class="closeTips" src="../mobile/assets/img/close-generate.png" alt="">
    </div>
    <div class="szsj_content">
        <p class="title_tips"><span class="red1">重要提示</span></p>
        <p class="explain_tips">1. 在采用实证数据时，我们会运用专业的评估模型来决定文章是否真正需要这些数据。<span class="red2">模型评估结果可能是整篇文章无需实证数据，那么将不会有实证数据出现在论文中。</span></p>
        <p class="explain_tips">2. <span class="red2">支付之前，请确认能接受机器生成带来的误差和局限性，再支付费用，确认支付后不接受任何形式退款。</span> </p>
        <p class="title_tips">什么是实证数据</p>
        <p class="explain_tips">实证数据是指从<span class="blue1">研究报告、财务报表、新闻报道以及权威机构</span>等渠道获取的各类真实数据，例如“国内生产总值（GDP）”、“贸易量”、“人口统计数据”等。<span class="blue1">这些数据可用于支持和证实论文中的观点。</span></p>
        <p class="title_tips">什么专业适用</p>
        <p class="explain_tips">1. <span class="blue2">“经济学”、“文学”、“法学”</span>等<span class="blue3">文科</span>专业，推荐使用实证数据来增强论文的说服力。</p>
        <p class="explain_tips noMarginBottom">2. <span class="blue2">“工程学”、“计算机科学”</span>等<span class="blue3">理工科</span>专业在决定是否使用实证数据时需要谨慎，因为这些领域的研究更侧重于<span class="blue2">理论和技术层面的探讨，会被认为不需要实证数据。</span></p>
    </div>
</div>
<div class="errTipBox">
    <div class="e_tittle">提示：</div>
    <p class="errTip_p"></p>
    <div class="y_e">确   定</div>
</div>
<div class="customer-wx">
    <img src="../mobile/assets/img/kfwx.png" alt="客服">
</div>
<div class="coupons_pop">
    <input  id="copyInput" type="text">
    <p class="title">是否使用免费券支付?</p>
    <p class="p2">订单编号: <span class="oid_pop"></span> <span class="copy_pop">复制</span></p>
    <p class="p3">订单编号是查询和下载报告的唯一标识，请妥善保存。</p>
    <div class="bottom">
        <div class="cancel_btn">取消</div>
        <div class="determine_btn">确定</div>
    </div>
</div>
<!-- 多码支付其他浏览器支付,提示弹窗 -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel"></h4>
            </div>
            <div class="modal-body">
<!--               <img src="../mobile/assets/img/cloneImg.png" alt=""> -->
                <div class="contentBox">
                    <p class="tips1">因数据安全问题暂不支持手机浏览器</p>
                    <p class="tips2">请复制链接至微信或电脑端打开</p>
                    <div class="linkUrl"></div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn_clone" data-dismiss="modal">复制链接</button>
            </div>
        </div>
    </div>
</div>
<!-- 淘宝支付弹窗 -->
<div class="modal fade" id="CustomModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button id="payClose" type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel1"><span id="typeName">淘宝</span>订单支付</h4>
            </div>
            <div class="modal-body">
<!--                <img src="../mobile/assets/img/cloneImg.png" alt="">-->
                <div class="contentBox taobaoPay">
                    <div class="taobao-input1">
                        <span>输入订单</span>
                        <input type="text" id="taobao-tid" placeholder="请输入您的淘宝订单编号">
                    </div>
                    <div class="taobao-input2">
                        <span>备用订单</span>
                        <input type="text" id="taobao-tid-1" placeholder="数额不足时填写，会合并数额">
                    </div>
                    <div class="taobao-payBtn">立即支付</div>
<!--                        <div class="taobao-buyBtn">-->
<!--                            <img src="{{ asset('projects/aipr/mobile/assets/img/taobaoBuy.png') }}" alt="">-->
<!--                            淘宝购买-->
<!--                        </div>-->
                </div>
            </div>
            <div class="modal-footer">

            </div>
        </div>
    </div>
</div>
<div id="customerOnline"></div>
<script src="../mobile/assets/js/jquery.min.js"></script>
<script src="../mobile/assets/js/bootstrap.min.js"></script>
<script src="../mobile/assets/js/clipboard.min.js"></script>
<script src="../mobile/assets/js/common.js?v=21.2"></script>
<script src="../mobile/assets/js/rotograph.js"></script>
<script src="../mobile/assets/js/message.js"></script>
<script src="../mobile/assets/js/ap.js?v=16"></script>
<script>
    toast({
        msg: '正在计算价格...',
        type: 'loading',
        time: 20000
    })

    var orderId = ''
    var payType = ""
    var time = 1800
    var source = 7
    var Timeout = ''
    var order_sn = getQueryVariable('commitId')
    var payId = getQueryVariable('payId')
    var payIs = false
    var isTips = true
    var noPayWay = false
    var openid = ''
    function llqType(pay_way) {
        if(pay_way.taobao){
            $(".taobao_pay").css('display' , 'flex')
        }
        if(pay_way.redBook){
            $(".redBook_pay").css('display' , 'flex')
        }

        if(pay_way.default == 'scanCodeRich') {
            if (/MicroMessenger/.test(window.navigator.userAgent)) {  // 微信浏览器
                source = 2
            }
            payType = "scanCodeRich"
            $('.payType').hide()
            payIs = true
            if(!(/MicroMessenger/.test(window.navigator.userAgent)) && !(/AlipayClient/.test(window.navigator.userAgent))) {
                $('.payBotton').attr('data-toggle' , "modal").attr("data-target" , "#myModal")
                isTips = true
                $('.linkUrl').text(window.location.href)
                return
            }
        }else {
            if (/MicroMessenger/.test(window.navigator.userAgent)) {    // 微信浏览器
                $('.isSelect2>.img').attr('src','../mobile/assets/img/select.png')
                $('.isSelect1>.img').attr('src','../mobile/assets/img/noselect.png')
                payType = "wxPublicNum"
                $('#wx-pay').attr('data-payType','wxPublicNum')
                source = 2

                $('.isSelect1>.img').attr('src','../mobile/assets/img/select.png')
                $('.isSelect2>.img').attr('src','../mobile/assets/img/noselect.png')
                payType = "alipayWap"
                $('#wx-pay').hide()  // 暂时隐藏微信支付, 微信支持后删除以上代码

                if(getQueryVariable('openid')){
                    $('.payType').show()
                    payIs = true
                    $('#wx-pay').show()
                    openid = getQueryVariable('openid')
                    if(pay_way.default == 'wx'){
                        $('.isSelect2>.img').attr('src','../mobile/assets/img/select.png')
                        $('.isSelect1>.img').attr('src','../mobile/assets/img/noselect.png')
                        payType = 'wxPublicNum'
                    }
                }

            }else if (/AlipayClient/.test(window.navigator.userAgent)) {     // 支付宝客户端
                $('.isSelect1>.img').attr('src','../mobile/assets/img/select.png')
                $('.isSelect2>.img').attr('src','../mobile/assets/img/noselect.png')
                payType = "alipayWap"
                $('#wx-pay').hide()  // 暂时隐藏微信支付
            }else {
                $('.isSelect1>.img').attr('src','../mobile/assets/img/select.png')
                $('.isSelect2>.img').attr('src','../mobile/assets/img/noselect.png')
                payType = "alipayWap"
                $('#wx-pay').hide()  // 暂时隐藏微信支付
            }

            //TODO 暂时只支持支付宝支付,如果支付宝支付不存在就删除支付方式禁止支付, 后期支持微信后再修改
            if(pay_way.alipay) {
                $('.payType').show()
                payIs = true
            }else{
                $(".payTypeBox[data-paytype='alipayWap']").hide()
            }

            // 默认支付方式为淘宝或小红书, 说明没有其他支付方式了
            if(pay_way.default == 'taobao' || pay_way.default == 'redBook') {
                $(".noPayWay").show();
                $(".bottomBox").hide()
            }
            if(pay_way.default == 'taobao'){
                if(pay_way.scanCodeRich){
                    payIs = true
                    payType = "scanCodeRich"
                    if(!(/MicroMessenger/.test(window.navigator.userAgent)) && !(/AlipayClient/.test(window.navigator.userAgent))) {
                        $('.payBotton').attr('data-toggle' , "modal").attr("data-target" , "#myModal")
                        isTips = true
                        $('.linkUrl').text(window.location.href)
                        return
                    }
                }
            }
        }

        isTips = false
    }

    $('.payTypeBox').click(function() {
        $('.payTypeBox .img').attr('src','../mobile/assets/img/noselect.png')
        $(this).children().children('.img').attr('src','../mobile/assets/img/select.png')
        payType = $(this).attr('data-payType')
    })

    $('#title').text(getQueryVariable('lw_type'))
    $('#NumberWords').text(getQueryVariable('NumberWords') + '字')
    $('#orderIdText').text(order_sn)
    $('#dateTime').text(getQueryVariable('dateTime'))
    if(getQueryVariable('PaperTypeName')) {
        $('.Subject').show()
        $('#PaperTypeName').text(getQueryVariable('PaperTypeName'))
    }else {
        $('.Subject').hide()
        $('#PaperTypeName').text('')
    }
    if(!order_sn) location.href='./index.html'

    function payWay(goods_info , pay_way) {
        if(getQueryVariable('contentType')){
            var typeData2 = typeData[getQueryVariable('contentType')] // 拿到当前版本的info参数
           if(typeData2){
               $('#typeTag').text(typeData2.name).show()
           }
        }

        if(getQueryVariable('orderType') == 'AIGC'){
            $('.NumberWordsBox').show()
            for(key in typeData) {
                if(typeData[key].name == getQueryVariable('orderKind')){
                    $("#typeTag").text(typeData[key].increment_goods_infos.zjcaigczz.name).show()
                    $("#priceTetx").text(typeData[key].increment_goods_infos.zjcaigczz.selling_price + '元/' + typeData[key].increment_goods_infos.zjcaigczz.unit_count + typeData[key].increment_goods_infos.zjcaigczz.unit_type)
                }
            }
            payStatus(order_sn)
        }

        var increment_goods_arr = []
        if(typeData2){
            for(var i in typeData2.increment_goods_infos) {
                increment_goods_arr.push(typeData2.increment_goods_infos[i])
            }
        }
        if(increment_goods_arr.length) { // 配置增值服务并配置默认选中
            var buttonDiv = ''
            for(var i=0; i<increment_goods_arr.length; i++) {
                for(var j=0; j<$(".appreciationLI").length; j++) {
                    if(increment_goods_arr[i].short_name == $($(".appreciationLI")[j]).attr('data-janename') || increment_goods_arr[i].short_name == $($(".appreciationLI")[j]).attr('data-janename1') ) {
                        $($(".appreciationLI")[j]).attr('goodsid-key',increment_goods_arr[i].goods_id)
                        $($(".appreciationLI")[j]).find('.good_name').text(increment_goods_arr[i].name)
                        if(increment_goods_arr[i].unit_type == '篇') {
                            $($(".appreciationLI")[j]).find('.current-price').text(increment_goods_arr[i].selling_price + '元')
                            $($(".appreciationLI")[j]).find('.original-price').text((increment_goods_arr[i].selling_price * 2).toFixed(2) + '元')
                        }else{
                            $($(".appreciationLI")[j]).find('.price').text(increment_goods_arr[i].selling_price + '元/' + increment_goods_arr[i].unit_count + increment_goods_arr[i].unit_type)
                        }
                        $($(".appreciationLI")[j]).show()
                        $($(".appreciationLI")[j]).css('display','flex')
                    }
                }
                if(getQueryVariable('zxktbg') && getQueryVariable('zxktbg')!=='false' && increment_goods_arr[i].short_name == 'ktbg'){
                    $(".appreciationLI[data-janename='ktbg']").hide()
                    $(".appreciationLI[data-janename='ktbg']").removeClass('selected')
                }
            }
            // $('.appreciationUL').html(buttonDiv)
            $('.appreciation').show()
            var goods = getQueryVariable('goods')? JSON.parse(getQueryVariable('goods')) : []
            for(var k = 0; k< $('.appreciationLI').length; k++) {
                if(goods.includes($('.appreciationLI').eq(k).attr('goodsId-key'))) {
                    $('.appreciationLI').eq(k).addClass('selected')
                }
            }
            /**
             判断goods是否存在数据
             index跳转过来goods为空,
             其他返回过来没有数据的情况下为[]
             所以只有index过来的时候才会给增值服务根据接口默认选中并切换了订单号
             **/
            if(!getQueryVariable('goods')) {
                for(var i=0; i<increment_goods_arr.length; i++) {
                    for(var j=0; j<$(".appreciationLI").length; j++) {
                        if(increment_goods_arr[i].short_name == $($(".appreciationLI")[j]).attr('data-janename') || increment_goods_arr[i].short_name == $($(".appreciationLI")[j]).attr('data-janename1')) {
                            if(increment_goods_arr[i].selection) {
                                $($(".appreciationLI")[j]).addClass('selected')
                            }
                        }
                    }
                }
                variationOrder()
            }else {
                toastNone()
                $('#amountText').text(getQueryVariable('order_amount'))
                $('#amountText2').text(getQueryVariable('order_amount'))
            }
        }else {
            toastNone()
            $('#amountText').text(getQueryVariable('order_amount'))
            $('#amountText2').text(getQueryVariable('order_amount'))
        }

        if(!pay_way.alipay && !pay_way.wx && !pay_way.scanCodeRich && !pay_way.taobao){
            noPayWay = true
        }
        if(noPayWay){
            $(".noPayWay").show();
            $(".no_pay_text").show();
            $(".payType").hide();
            $(".bottomBox").hide();
        }

        llqType(pay_way)

        if(typeData2){
            if(typeData2.unit_type == '字') {
                $('#priceTetx').text(typeData2.selling_price+'元/'+typeData2.unit_count+typeData2.unit_type)
                $('#priceTetx2').text(typeData2.selling_price+'元/'+typeData2.unit_count+typeData2.unit_type)
                $('.NumberWordsBox').show()
            }else {
                $('#priceTetx').text(typeData2.selling_price+'元/每'+typeData2.unit_type)
                $('#priceTetx2').text(typeData2.selling_price+'元/每'+typeData2.unit_type)
            }
        }
    }
    $('.payBotton').click(function() {
        if(isTips) return
        if(!payIs) return toast({msg: '暂未配置支付'})
        if(payType == 'scanCodeRich') {
            editUrl(order_sn)
            window.location.href = getQueryVariable('pay_wap_url') + '/pay/waporder/' + order_sn + '?source=' + source
        }else if(payType == 'wxPublicNum'){
            var formData = getFormData({
                order_sn: order_sn,
                pay_type: payType,
                source,
                openid: openid,
            })
            $.ajax({
                type: "POST",
                url:urls + '/api/client/pay/payOrder',
                processData: false,
                contentType: false,
                xhrFields: {
                    withCredentials: true
                },
                data: formData,
                success: function (resX) {
                    if(resX.code !== 200){
                        toast(resX.codeMsg)
                        if(resX.code == 3001){
                            toast('订单已支付')
                            window.location.href = "./query.html?oid=" + order_sn;
                        }
                        return
                    }
                    if (typeof WeixinJSBridge == "undefined") {
                        if (document.addEventListener) {
                            document.addEventListener(
                                "WeixinJSBridgeReady",
                                onBridgeReady,
                                false
                            );
                        } else if (document.attachEvent) {
                            document.attachEvent("WeixinJSBridgeReady", onBridgeReady);
                            document.attachEvent("onWeixinJSBridgeReady", onBridgeReady);
                        }
                    } else {
                        onBridgeReady(resX.data);
                    }
                    function onBridgeReady(data) {
                        // let wxData = Object.assign({
                        //     "appId": "wxafff7239b695dce5",
                        // }, data)
                        // console.log(data, "=========");
                        window.WeixinJSBridge.invoke(
                            "getBrandWCPayRequest",
                            {
                                appId: payWay_Info.wx_jsapi, //公众号名称，由商户传入
                                timeStamp: data.timeStamp + "", //时间戳，自1970年以来的秒数
                                nonceStr: data.nonceStr, //随机串
                                package: "prepay_id=" + data.package,
                                signType: data.signType, //微信签名方式：
                                paySign: data.paySign, //微信签名
                                jsApiList: ["chooseWXPay"]
                            },
                            function(res) {
                                if (res.err_msg == "get_brand_wcpay_request:ok") {
                                    // 使用以上方式判断前端返回,微信团队郑重提示：
                                    //res.err_msg将在用户支付成功后返回ok，但并不保证它绝对可靠。
                                }else{ //跳转支付失败页
                                    toast('支付失败')
                                }
                            }
                        );
                    }
                },
                error: function () {
                    toast("网络错误！")
                }
            })
        }else{
            var formData = getFormData({
                order_sn: order_sn,
                pay_type: payType,
                source,
                return_url: "./pay_result.html?oid=" + order_sn + "&price= "+$('#amountText').text()+"" + "&payType="+ payType + ""
            })
            toast({
                msg: '正在跳转支付...',
                type: 'loading'
            })
            $.ajax({
                type: 'post',
                url: urls + '/api/client/pay/payOrder',
                processData: false,
                contentType: false,
                xhrFields: {
                    withCredentials: true
                },
                data: formData,
                success: function(data) {
                    if(data.code == 200) {
                        if(/MicroMessenger/.test(window.navigator.userAgent) && payType == 'alipayWap') { // 微信浏览器且支付宝支付跳转之间页
                            _AP.pay(data.data.payUrl);
                        }else {
                            window.location.href = data.data.payUrl
                        }
                        editUrl(data.data.pay_id)
                    }else if(data.code == 3001) {
                        toast('订单已支付')
                        window.location.href = "./query.html?oid=" + order_sn;
                    } else {
                        toast({
                            msg: data.codeMsg,
                            type: 'error',
                            time: 2000
                        })
                    }
                },
                error: function(err) {
                    toast({
                        msg: "请求失败!请检查网络",
                        type: 'error',
                        time: 2000
                    })
                }
            });
        }
    })

    var zdyPayType = ''
    // 自定义订单切换
    $('.dsf-Pay').click(function() {
        var dsfData = {
            redBook: {
                name: '小红书',
                placeholder: '请填写小红书订单编号'
            },
            taobao: {
                name: '淘宝',
                placeholder: '请填写淘宝订单编号'
            }
        }
        $('#typeName').text(dsfData[$(this).attr('data-type')].name)
        $('#taobao-tid').attr('placeholder' , dsfData[$(this).attr('data-type')].placeholder)
        zdyPayType = $(this).attr('data-type')
    })

    $('#CustomModal').on('hidden.bs.modal', function (e) {
        $("#taobao-tid").val('')
        $('#taobao-tid-1').val('')
    })
    // 自定义订单支付
    let TbPaying = false
    $(".taobao-payBtn").click(function (){
        if(TbPaying){
            return;
        }
        if(!$("#taobao-tid").val()){
            toast('请填写淘宝订单编号')
            return;
        }
        toast({
            msg: '正在支付...',
            type: 'loading',
            time: 20000
        })
        TbPaying = true
        let formData = getFormData({
            order_sn: order_sn,
            pay_type: zdyPayType,
            source,
            tids: $("#taobao-tid").val() + ($('#taobao-tid-1').val()?(','+$('#taobao-tid-1').val()):'')
        })
        $.ajax({
            type: 'post',
            url: urls + '/api/client/pay/payOrder',
            processData: false,
            contentType: false,
            xhrFields: {
                withCredentials: true
            },
            data: formData,
            success: function (data) {
                TbPaying = false
                if(data.code == 200){

                }else{
                    if(data.code == 3001){
                        toast('支付成功')
                        window.location.href = "./query.html?oid=" + order_sn + '&editionType=' + getQueryVariable('editionType');
                        return
                    }else{
                        toast({
                            msg: data.codeMsg,
                            type: 'error',
                            time: 3000
                        })
                    }
                }
            },
            error: function (err) {
                TbPaying = false
            },
            complete: function (){

            }
        })
    })
    function editUrl(pay_id) {
        // 修改url参数保留数据,防止返回这个页面数据发生变化
        replaceParamVal('commitId' , order_sn , 0)
        replaceParamVal('order_amount' , $('#amountText').text() , 0)
        var goodsTo = JSON.stringify(goods())
        replaceParamVal('goods' , goodsTo||'' , 0)
        replaceParamVal('payId' , pay_id , 0)
    }
    function payStatus(id) { // 轮询
        $.ajax({
            type: "get",
            url: urls + '/apirs/order/is_pay?pay_id=' + id,
            xhrFields: {
                withCredentials: true
            },
            success: function (res) {
                clearTimeout(Timeout);
                if (!res.data) {
                    Timeout = setTimeout(function () {
                        payStatus(id);
                    }, 1000);
                }else {
                    window.location.href = "./pay_result.html?oid=" + id + "&price= "+$('#amountText').text()+"" + "&payType="+ payType + "" ;
                }
            },
            error: function () {
                toast({
                    msg: "请求失败!请检查网络",
                    type: 'error',
                    time: 2000
                })
            },
        });
    }
    if(payId) payStatus(payId)

    var contentTypeIs = true
    $(".appreciationUL").on('click','.appreciationLI',function(){
        if(!contentTypeIs) return
        toast({
            msg: '正在重新计算价格...',
            type: 'loading',
            time: 20000
        })
        $('#amountText').text('0.00')
        contentTypeIs = false
        if($(this).hasClass('selected')) {
            $(this).removeClass('selected')
        }else {
            $(this).addClass('selected')
        }
        var formData = getFormData({
            order_sn: order_sn,
            goods: goods().toString(),
        })
        $.ajax({
            type: 'post',
            url: urls + '/api/client/order/variation/order',
            data: formData,
            contentType: false,
            processData: false,
            xhrFields: {
                withCredentials: true
            },
            success: function (res) {
                if (res.code == 200) {
                    order_sn = res.data.order_sn
                    $('#amountText').text(res.data.order_amount)
                    $('#amountText2').text(res.data.order_amount)
                    $('#dateTime').text(res.data.created)
                    $('#orderIdText').text(res.data.order_sn)
                    payStatus(order_sn)
                    toastNone()
                }else {
                    toast({
                        msg: "增值服务选择失败!",
                        type: 'error',
                        time: 2000
                    })
                    if($(this).hasClass('selected')) {
                        $(this).removeClass('selected')
                    }else {
                        $(this).addClass('selected')
                    }
                }
                contentTypeIs=true
            },
            error: function () {
                toastNone()
                toast({
                    msg: "请求失败!请检查网络",
                    type: 'error',
                    time: 2000
                })
                contentTypeIs=true
            },
        });
    });

    function goods() {
        // 组装goods
        var goods = []
        for(var i = 0; i< $('.appreciationLI').length; i++) {
            if($('.appreciationLI').eq(i).hasClass('selected') && $('.appreciationLI').eq(i).is(':visible')) {
                goods.push($('.appreciationLI').eq(i).attr('goodsId-key'))
            }
        }
        return goods
    }
    // 修改url参数
    function replaceParamVal(name, val, isRefresh) {
        var url = this.location.href.toString();
        var pattern = "[\?]" + name + '=([^&]*)';
        var pattern2 = "[&]" + name + '=([^&]*)';
        var replaceText = name + '=' + val;
        var replaceText1 = "\?" + replaceText;
        var replaceText2 = "&" + replaceText;
        if (url.match(pattern)) {
            var tmp = '/\\?(' + name + '=)([^&]*)/gi';
            var nUrl = url.replace(eval(tmp), replaceText1);;
        } else if (url.match(pattern2)) {
            var tmp = '/&(' + name + '=)([^&]*)/gi';
            var nUrl = url.replace(eval(tmp), replaceText2);;
        }
        else {
            if (url.match('[\?]')) {
                var nUrl= url + '&' + replaceText;
            } else {
                var nUrl= url + '?' + replaceText;
            }
        }
        if (isRefresh) {
            window.location.href = nUrl
        }
        var stateObject = { id: "" };
        var title = "";
        history.replaceState(stateObject, title, nUrl);
    }

    // TODO 默认选中增值服务
    function variationOrder() {
        $('#amountText').text('0.00')
        contentTypeIs = false
        var formData = getFormData({
            order_sn: order_sn,
            goods: goods().toString(),
        })
        $.ajax({
            type: 'post',
            url: urls + '/api/client/order/variation/order',
            data: formData,
            contentType: false,
            processData: false,
            xhrFields: {
                withCredentials: true
            },
            success: function (res) {
                if (res.code == 200) {
                    order_sn = res.data.order_sn
                    $('#amountText').text(res.data.order_amount)
                    $('#amountText2').text(res.data.order_amount)
                    $('#dateTime').text(res.data.created)
                    $('#orderIdText').text(res.data.order_sn)
                    payStatus(order_sn)
                }
                contentTypeIs=true
                toastNone()
            },
            error: function () {
                toastNone()
                toast({
                    msg: "请求失败!请检查网络",
                    type: 'error',
                    time: 2000
                })
                contentTypeIs=true
                toastNone()
            },
        });
    }

    var clipboard = new Clipboard('.btn_clone', {
        text: function () {
            return $('.linkUrl').text();
        },
    });

    //复制成功响应
    clipboard.on('success', function (e) {
        toast({
            msg: "复制成功",
            type: 'success',
            time: 2000
        })
    });

    //复制失败响应
    clipboard.on('error', function (e) {
        toast({
            msg: "复制失败!请重新尝试",
            type: 'error',
            time: 2000
        })
    });

    $(".mask").on('click',function (){
        $(".mask").hide();
        $(".errTipBox").hide()
        $(".coupons_pop").hide();
        $(".aigc-page").hide();
        $(".szsj-tips-block").hide();
    })

    $(".mask").on('click',function (){
        $(".mask").hide();
        $(".aigc-page").hide();
    })

    $(".aigc-page").on('click',function (){
        $(".mask").hide();
        $(".aigc-page").hide();
    })

    $(".y_e").on('click',function (){
        $(".mask").hide();
        $(".errTipBox").hide()
    })

    $(".cancel_btn").on('click',function (){
        $(".mask").hide();
        $(".coupons_pop").hide();
    })

    $(".determine_btn").on('click',function (){
        couponsPay()
    })

    let canClick = true;
    //优惠券
    $("#coupon").on('input',function (){
        if($(this).val().length > 0){
            $(".use_now").addClass('active')
        }else{
            $(".use_now").removeClass('active')
        }
    })

    function couponsPay(){
        var formData2 = getFormData({
            order_sn: order_sn,
            pay_type: 'coupons',
            source
        })
        $.ajax({
            type: 'post',
            url: urls + '/api/client/pay/payOrder',
            processData: false,
            contentType: false,
            xhrFields: {
                withCredentials: true
            },
            data: formData2,
            success: function(data) {
                if(data.code == 200) {
                    if(/MicroMessenger/.test(window.navigator.userAgent) && payType == 'alipayWap') {
                        _AP.pay(data.data.payUrl);
                    }else {
                        window.location.href = data.data.payUrl
                    }
                    // 修改url参数保留数据,防止返回这个页面数据发生变化
                    replaceParamVal('commitId' , order_sn , 0)
                    replaceParamVal('order_amount' , $('#amountText').text() , 0)
                    var goodsTo = JSON.stringify(goods())
                    replaceParamVal('goods' , goodsTo||'' , 0)
                    replaceParamVal('payId' , data.data.pay_id , 0)
                }else if(data.code == 3001) {
                    toast('订单已支付')
                    window.location.href = "./query.html?oid=" + order_sn;
                } else {
                    toast({
                        msg: data.codeMsg,
                        type: 'error',
                        time: 2000
                    })
                }
            },
            error: function(err) {
                toast({
                    msg: "请求失败!请检查网络",
                    type: 'error',
                    time: 2000
                })
            }
        });
    }

    $(".copy_pop").on('click',function (){
        var text = $(".oid_pop").text()
        $("#copyInput").val(text)
        $("#copyInput").select()
        try {
            var state = document.execCommand("copy");
        } catch (err) {
            var state = false;
        }
        if (state) {
            toast('复制成功')
        } else {
            toast({
                msg: "复制失败,请手动复制",
                type: 'error',
                time: 2000
            })
        }
    })

    $(".use_now").on('click',function (){
        if(!$("#coupon").val().length){
            toast({
                msg: "请输入优惠券码",
                type: 'error',
                time: 2000
            })
            return;
        }
        if(!canClick) return;
        canClick = false
        toast({
            msg: '正在兑换优惠券...',
            type: 'loading',
            time: 20000
        })

        contentTypeIs = false
        var formData = getFormData({
            order_sn: order_sn,
            goods: goods().toString(),
            code: $("#coupon").val()
        })
        $.ajax({
            type: 'post',
            url: urls + '/api/client/order/variation/order',
            data: formData,
            contentType: false,
            processData: false,
            xhrFields: {
                withCredentials: true
            },
            success: function (res) {
                toastNone()
                if (res.code == 200) {
                    order_sn = res.data.order_sn
                    // $('#amountText2').text(res.data.order_amount)
                    // $('#amountText').text(res.data.order_amount)
                    $('#dateTime').text(res.data.created)
                    $('#orderIdText').text(res.data.order_sn)
                    $(".oid_pop").text(res.data.order_sn)
                    // payStatus(order_sn)
                    if(Number(res.data.order_amount) == 0) {
                        $(".mask").show();
                        $(".coupons_pop").show()
                    }else{
                        $('#amountText2').text(res.data.order_amount)
                        $('#amountText').text(res.data.order_amount)
                    }
                }else{
                    $(".errTip_p").text(res.codeMsg)
                    $(".errTipBox").show();
                    $(".mask").show();
                }
                contentTypeIs=true
                canClick = true
            },
            error: function () {
                toastNone()
                toast({
                    msg: "请求失败!请检查网络",
                    type: 'error',
                    time: 2000
                })
                contentTypeIs=true
                canClick = true
            },
        })
    })

    $(".zjc-wh").on('click', function (e){
        $(".aigc-page").show()
        $(".aigc-page").css('display','flex')
        $(".mask").show()
        e.stopPropagation();
    })

    $(".szsj_notice").click(function (e){
        $(".mask").show()
        $(".szsj-tips-block").show()
        e.stopPropagation();
    })

    $(".closeTips").click(function (){
        $(".mask").hide()
        $(".szsj-tips-block").hide()
    })
</script>
</body>
</html>
